<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang="en" dir="ltr" class="client-nojs">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>C++ concepts: Allocator - cppreference.com</title>
<meta charset="UTF-8">
<meta name="generator" content="MediaWiki 1.21.2">


<link rel="shortcut icon" href="../../../favicon.ico">



<link rel="stylesheet" href="../../../common/ext.css">
<meta name="ResourceLoaderDynamicStyles" content="">
<link rel="stylesheet" href="../../../common/site_modules.css">
<style>a:lang(ar),a:lang(ckb),a:lang(fa),a:lang(kk-arab),a:lang(mzn),a:lang(ps),a:lang(ur){text-decoration:none}#toc{display:none}.editsection{display:none}
/* cache key: mwiki1-mwiki_en_:resourceloader:filter:minify-css:7:472787eddcf4605d11de8c7ef047234f */</style>

<script src="../../../common/startup_scripts.js"></script>
<script>if(window.mw){
mw.config.set({"wgCanonicalNamespace":"","wgCanonicalSpecialPageName":false,"wgNamespaceNumber":0,"wgPageName":"cpp/concept/Allocator","wgTitle":"cpp/concept/Allocator","wgCurRevisionId":68221,"wgArticleId":9133,"wgIsArticle":true,"wgAction":"view","wgUserName":null,"wgUserGroups":["*"],"wgCategories":[],"wgBreakFrames":false,"wgPageContentLanguage":"en","wgSeparatorTransformTable":["",""],"wgDigitTransformTable":["",""],"wgDefaultDateFormat":"dmy","wgMonthNames":["","January","February","March","April","May","June","July","August","September","October","November","December"],"wgMonthNamesShort":["","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],"wgRelevantPageName":"cpp/concept/Allocator","wgRestrictionEdit":[],"wgRestrictionMove":[]});
}</script><script>if(window.mw){
mw.loader.implement("user.options",function(){mw.user.options.set({"ccmeonemails":0,"cols":80,"date":"default","diffonly":0,"disablemail":0,"disablesuggest":0,"editfont":"default","editondblclick":0,"editsection":0,"editsectiononrightclick":0,"enotifminoredits":0,"enotifrevealaddr":0,"enotifusertalkpages":1,"enotifwatchlistpages":0,"extendwatchlist":0,"externaldiff":0,"externaleditor":0,"fancysig":0,"forceeditsummary":0,"gender":"unknown","hideminor":0,"hidepatrolled":0,"imagesize":2,"justify":0,"math":1,"minordefault":0,"newpageshidepatrolled":0,"nocache":0,"noconvertlink":0,"norollbackdiff":0,"numberheadings":0,"previewonfirst":0,"previewontop":1,"quickbar":5,"rcdays":7,"rclimit":50,"rememberpassword":0,"rows":25,"searchlimit":20,"showhiddencats":0,"showjumplinks":1,"shownumberswatching":1,"showtoc":0,"showtoolbar":1,"skin":"cppreference2","stubthreshold":0,"thumbsize":2,"underline":2,"uselivepreview":0,"usenewrc":0,"watchcreations":0,"watchdefault":0,"watchdeletion":0,
"watchlistdays":3,"watchlisthideanons":0,"watchlisthidebots":0,"watchlisthideliu":0,"watchlisthideminor":0,"watchlisthideown":0,"watchlisthidepatrolled":0,"watchmoves":0,"wllimit":250,"variant":"en","language":"en","searchNs0":true,"searchNs1":false,"searchNs2":false,"searchNs3":false,"searchNs4":false,"searchNs5":false,"searchNs6":false,"searchNs7":false,"searchNs8":false,"searchNs9":false,"searchNs10":false,"searchNs11":false,"searchNs12":false,"searchNs13":false,"searchNs14":false,"searchNs15":false,"gadget-ColiruCompiler":1});;},{},{});mw.loader.implement("user.tokens",function(){mw.user.tokens.set({"editToken":"+\\","patrolToken":false,"watchToken":false});;},{},{});
/* cache key: mwiki1-mwiki_en_:resourceloader:filter:minify-js:7:ca03345b1e2c4d90a25d968753a73b92 */
}</script>
<script>if(window.mw){
mw.loader.load(["mediawiki.page.startup","mediawiki.legacy.wikibits","mediawiki.legacy.ajax"]);
}</script>
<style type="text/css">/*<![CDATA[*/
.source-cpp {line-height: normal;}
.source-cpp li, .source-cpp pre {
	line-height: normal; border: 0px none white;
}
/**
 * GeSHi Dynamically Generated Stylesheet
 * --------------------------------------
 * Dynamically generated stylesheet for cpp
 * CSS class: source-cpp, CSS id: 
 * GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann
 * (http://qbnz.com/highlighter/ and http://geshi.org/)
 * --------------------------------------
 */
.cpp.source-cpp .de1, .cpp.source-cpp .de2 {font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;}
.cpp.source-cpp  {font-family:monospace;}
.cpp.source-cpp .imp {font-weight: bold; color: red;}
.cpp.source-cpp li, .cpp.source-cpp .li1 {font-weight: normal; vertical-align:top;}
.cpp.source-cpp .ln {width:1px;text-align:right;margin:0;padding:0 2px;vertical-align:top;}
.cpp.source-cpp .li2 {font-weight: bold; vertical-align:top;}
.cpp.source-cpp .kw1 {color: #0000dd;}
.cpp.source-cpp .kw2 {color: #0000ff;}
.cpp.source-cpp .kw3 {color: #0000dd;}
.cpp.source-cpp .kw4 {color: #0000ff;}
.cpp.source-cpp .co1 {color: #909090;}
.cpp.source-cpp .co2 {color: #339900;}
.cpp.source-cpp .coMULTI {color: #ff0000; font-style: italic;}
.cpp.source-cpp .es0 {color: #008000; font-weight: bold;}
.cpp.source-cpp .es1 {color: #008000; font-weight: bold;}
.cpp.source-cpp .es2 {color: #008000; font-weight: bold;}
.cpp.source-cpp .es3 {color: #008000; font-weight: bold;}
.cpp.source-cpp .es4 {color: #008000; font-weight: bold;}
.cpp.source-cpp .es5 {color: #008000; font-weight: bold;}
.cpp.source-cpp .br0 {color: #008000;}
.cpp.source-cpp .sy0 {color: #008000;}
.cpp.source-cpp .sy1 {color: #000080;}
.cpp.source-cpp .sy2 {color: #000040;}
.cpp.source-cpp .sy3 {color: #000040;}
.cpp.source-cpp .sy4 {color: #008080;}
.cpp.source-cpp .st0 {color: #008000;}
.cpp.source-cpp .nu0 {color: #000080;}
.cpp.source-cpp .nu6 {color: #000080;}
.cpp.source-cpp .nu8 {color: #000080;}
.cpp.source-cpp .nu12 {color: #000080;}
.cpp.source-cpp .nu16 {color:#000080;}
.cpp.source-cpp .nu17 {color:#000080;}
.cpp.source-cpp .nu18 {color:#000080;}
.cpp.source-cpp .nu19 {color:#000080;}
.cpp.source-cpp .ln-xtra, .cpp.source-cpp li.ln-xtra, .cpp.source-cpp div.ln-xtra {background-color: #ffc;}
.cpp.source-cpp span.xtra { display:block; }

/*]]>*/
</style>
<!--[if lt IE 7]><style type="text/css">body{behavior:url("/mwiki/skins/cppreference2/csshover.min.htc")}</style><![endif]-->
</head>
<body class="mediawiki ltr sitedir-ltr ns-0 ns-subject page-cpp_concept_Allocator skin-cppreference2 action-view cpp-navbar">
        <!-- header -->
        
        <!-- /header -->
        <!-- content -->
        <div id="cpp-content-base">
            <div id="content">
                <a id="top"></a>
                <div id="mw-js-message" style="display:none;"></div>
                                <!-- firstHeading -->
                <h1 id="firstHeading" class="firstHeading">
<span style="font-size:0.7em; line-height:130%">C++ concepts:</span> Allocator</h1>
                <!-- /firstHeading -->
                <!-- bodyContent -->
                <div id="bodyContent">
                                        <!-- tagline -->
                    <div id="siteSub">From cppreference.com</div>
                    <!-- /tagline -->
                                        <!-- subtitle -->
                    <div id="contentSub"><span class="subpages">&lt; <a href="../../cpp.html" title="cpp">cpp</a>‎ | <a href="../concept.html" title="cpp/concept">concept</a></span></div>
                    <!-- /subtitle -->
                                                            <!-- bodycontent -->
                    <div id="mw-content-text" lang="en" dir="ltr" class="mw-content-ltr">
<div class="t-navbar" style="">
<div class="t-navbar-sep"> </div>
<div class="t-navbar-head">
<a href="../../cpp.html" title="cpp"> C++</a><div class="t-navbar-menu"><div>
<div><table class="t-nv-begin" cellpadding="0" style="line-height:1.1em;">
<tr class="t-nv"><td colspan="5"> <a href="../language.1.html" title="cpp/language"> Language</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../header.html" title="cpp/header"> Standard library headers</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../concept.html" title="cpp/concept"> Concepts</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../utility.html" title="cpp/utility"> Utilities library</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../string.html" title="cpp/string"> Strings library</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../container.html" title="cpp/container"> Containers library</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../algorithm.html" title="cpp/algorithm"> Algorithms library</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../iterator.html" title="cpp/iterator"> Iterators library</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../numeric.html" title="cpp/numeric"> Numerics library</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../io.html" title="cpp/io"> Input/output library</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../locale.html" title="cpp/locale"> Localizations library</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../regex.html" title="cpp/regex"> Regular expressions library</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../atomic.html" title="cpp/atomic"> Atomic operations library</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../thread.html" title="cpp/thread"> Thread support library</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span> </td></tr>
</table></div>
<div></div>
</div></div>
</div>
<div class="t-navbar-sep"> </div>
<div class="t-navbar-head">
<a href="../concept.html" title="cpp/concept"> C++ concepts</a><div class="t-navbar-menu"><div>
<div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv-h1"><td colspan="5"> Basic</td></tr>
<tr class="t-nv-col-table">
<td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="DefaultConstructible.html" title="cpp/concept/DefaultConstructible"><span class="t-lines"><span>DefaultConstructible</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="CopyAssignable.html" title="cpp/concept/CopyAssignable"><span class="t-lines"><span>CopyAssignable</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="CopyConstructible.html" title="cpp/concept/CopyConstructible"><span class="t-lines"><span>CopyConstructible</span></span></a></div></div></td></tr>
</table></div></td>
<td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table">
<div><a href="MoveAssignable.html" title="cpp/concept/MoveAssignable"><span class="t-lines"><span>MoveAssignable</span></span></a></div>
<div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div>
</div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table">
<div><a href="MoveConstructible.html" title="cpp/concept/MoveConstructible"><span class="t-lines"><span>MoveConstructible</span></span></a></div>
<div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div>
</div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="Destructible.html" title="cpp/concept/Destructible"><span class="t-lines"><span>Destructible</span></span></a></div></div></td></tr>
</table></div></td>
</tr>
<tr class="t-nv-h1"><td colspan="5"> Library-Wide</td></tr>
<tr class="t-nv-col-table">
<td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="EqualityComparable.html" title="cpp/concept/EqualityComparable"><span class="t-lines"><span>EqualityComparable</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="LessThanComparable.html" title="cpp/concept/LessThanComparable"><span class="t-lines"><span>LessThanComparable</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table">
<div><a href="Swappable.html" title="cpp/concept/Swappable"><span class="t-lines"><span>Swappable</span></span></a></div>
<div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div>
</div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table">
<div><a href="ValueSwappable.html" title="cpp/concept/ValueSwappable"><span class="t-lines"><span>ValueSwappable</span></span></a></div>
<div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div>
</div></td></tr>
</table></div></td>
<td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table">
<div><a href="NullablePointer.html" title="cpp/concept/NullablePointer"><span class="t-lines"><span>NullablePointer</span></span></a></div>
<div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div>
</div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table">
<div><a href="Hash.html" title="cpp/concept/Hash"><span class="t-lines"><span>Hash</span></span></a></div>
<div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div>
</div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><strong class="selflink"><span class="t-lines"><span>Allocator</span></span></strong></div></div></td></tr>
</table></div></td>
</tr>
<tr class="t-nv-h1"><td colspan="5"> Container</td></tr>
<tr class="t-nv-col-table">
<td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="Container.html" title="cpp/concept/Container"><span class="t-lines"><span>Container</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="SequenceContainer.html" title="cpp/concept/SequenceContainer"><span class="t-lines"><span>SequenceContainer</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="ReversibleContainer.html" title="cpp/concept/ReversibleContainer"><span class="t-lines"><span>ReversibleContainer</span></span></a></div></div></td></tr>
</table></div></td>
<td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="AssociativeContainer.html" title="cpp/concept/AssociativeContainer"><span class="t-lines"><span>AssociativeContainer</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="AllocatorAwareContainer.html" title="cpp/concept/AllocatorAwareContainer"><span class="t-lines"><span>AllocatorAwareContainer</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table">
<div><a href="http%3A//en.cppreference.com/mwiki/index.php" class="new" title="cpp/concept/UnorderedAssociativeContainer (page does not exist)"><span class="t-lines"><span>UnorderedAssociativeContainer</span></span></a></div>
<div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div>
</div></td></tr>
</table></div></td>
</tr>
<tr class="t-nv-h2"><td colspan="5"> Container Elements</td></tr>
<tr class="t-nv-col-table">
<td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table">
<div><a href="CopyInsertable.html" title="cpp/concept/CopyInsertable"><span class="t-lines"><span>CopyInsertable</span></span></a></div>
<div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div>
</div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table">
<div><a href="MoveInsertable.html" title="cpp/concept/MoveInsertable"><span class="t-lines"><span>MoveInsertable</span></span></a></div>
<div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div>
</div></td></tr>
</table></div></td>
<td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table">
<div><a href="EmplaceConstructible.html" title="cpp/concept/EmplaceConstructible"><span class="t-lines"><span>EmplaceConstructible</span></span></a></div>
<div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div>
</div></td></tr>
</table></div></td>
</tr>
<tr class="t-nv-h1"><td colspan="5"> Iterator</td></tr>
<tr class="t-nv-col-table">
<td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="Iterator.html" title="cpp/concept/Iterator"><span class="t-lines"><span>Iterator</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="OutputIterator.html" title="cpp/concept/OutputIterator"><span class="t-lines"><span>OutputIterator</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="InputIterator.html" title="cpp/concept/InputIterator"><span class="t-lines"><span>InputIterator</span></span></a></div></div></td></tr>
</table></div></td>
<td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="ForwardIterator.html" title="cpp/concept/ForwardIterator"><span class="t-lines"><span>ForwardIterator</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="BidirectionalIterator.html" title="cpp/concept/BidirectionalIterator"><span class="t-lines"><span>BidirectionalIterator</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="RandomAccessIterator.html" title="cpp/concept/RandomAccessIterator"><span class="t-lines"><span>RandomAccessIterator</span></span></a></div></div></td></tr>
</table></div></td>
</tr>
<tr class="t-nv-h1"><td colspan="5"> Stream I/O</td></tr>
<tr class="t-nv-col-table">
<td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="FormattedInputFunction.html" title="cpp/concept/FormattedInputFunction"><span class="t-lines"><span>FormattedInputFunction</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="UnformattedInputFunction.html" title="cpp/concept/UnformattedInputFunction"><span class="t-lines"><span>UnformattedInputFunction</span></span></a></div></div></td></tr>
</table></div></td>
<td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="FormattedOutputFunction.html" title="cpp/concept/FormattedOutputFunction"><span class="t-lines"><span>FormattedOutputFunction</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="UnformattedOutputFunction.html" title="cpp/concept/UnformattedOutputFunction"><span class="t-lines"><span>UnformattedOutputFunction</span></span></a></div></div></td></tr>
</table></div></td>
</tr>
<tr class="t-nv-h1"><td colspan="5"> Random Numbers</td></tr>
<tr class="t-nv-col-table">
<td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table">
<div><a href="SeedSequence.html" title="cpp/concept/SeedSequence"><span class="t-lines"><span>SeedSequence</span></span></a></div>
<div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div>
</div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table">
<div><a href="http%3A//en.cppreference.com/mwiki/index.php" class="new" title="cpp/concept/RandomNumberEngine (page does not exist)"><span class="t-lines"><span>RandomNumberEngine</span></span></a></div>
<div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div>
</div></td></tr>
</table></div></td>
<td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table">
<div><a href="RandomNumberDistribution.html" title="cpp/concept/RandomNumberDistribution"><span class="t-lines"><span>RandomNumberDistribution</span></span></a></div>
<div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div>
</div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table">
<div><a href="http%3A//en.cppreference.com/mwiki/index.php" class="new" title="cpp/concept/UniformRandomNumberGenerator (page does not exist)"><span class="t-lines"><span>UniformRandomNumberGenerator</span></span></a></div>
<div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div>
</div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table">
<div><a href="http%3A//en.cppreference.com/mwiki/index.php" class="new" title="cpp/concept/RandomNumberEngineAdaptor (page does not exist)"><span class="t-lines"><span>RandomNumberEngineAdaptor</span></span></a></div>
<div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div>
</div></td></tr>
</table></div></td>
</tr>
<tr class="t-nv-h1"><td colspan="5"> Concurrency</td></tr>
<tr class="t-nv-col-table">
<td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table">
<div><a href="BasicLockable.html" title="cpp/concept/BasicLockable"><span class="t-lines"><span>BasicLockable</span></span></a></div>
<div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div>
</div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table">
<div><a href="Lockable.html" title="cpp/concept/Lockable"><span class="t-lines"><span>Lockable</span></span></a></div>
<div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div>
</div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table">
<div><a href="TimedLockable.html" title="cpp/concept/TimedLockable"><span class="t-lines"><span>TimedLockable</span></span></a></div>
<div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div>
</div></td></tr>
</table></div></td>
<td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table">
<div><a href="Mutex.html" title="cpp/concept/Mutex"><span class="t-lines"><span>Mutex</span></span></a></div>
<div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div>
</div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table">
<div><a href="TimedMutex.html" title="cpp/concept/TimedMutex"><span class="t-lines"><span>TimedMutex</span></span></a></div>
<div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div>
</div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table">
<div><a href="SharedMutex.html" title="cpp/concept/SharedMutex" class="mw-redirect"><span class="t-lines"><span>SharedMutex</span></span></a></div>
<div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx14">(C++14)</span></span></span></div>
</div></td></tr>
</table></div></td>
</tr>
<tr class="t-nv-h1"><td colspan="5"> Other</td></tr>
<tr class="t-nv-col-table">
<td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="http%3A//en.cppreference.com/mwiki/index.php" class="new" title="cpp/concept/CharTraits (page does not exist)"><span class="t-lines"><span>CharTraits</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="http%3A//en.cppreference.com/mwiki/index.php" class="new" title="cpp/concept/pos type (page does not exist)"><span class="t-lines"><span>pos_type</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="http%3A//en.cppreference.com/mwiki/index.php" class="new" title="cpp/concept/off type (page does not exist)"><span class="t-lines"><span>off_type</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table">
<div><a href="Clock.html" title="cpp/concept/Clock"><span class="t-lines"><span>Clock</span></span></a></div>
<div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div>
</div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="BitmaskType.html" title="cpp/concept/BitmaskType"><span class="t-lines"><span>BitmaskType</span></span></a></div></div></td></tr>
</table></div></td>
<td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table">
<div><a href="http%3A//en.cppreference.com/mwiki/index.php" class="new" title="cpp/concept/UnaryTypeTrait (page does not exist)"><span class="t-lines"><span>UnaryTypeTrait</span></span></a></div>
<div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div>
</div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table">
<div><a href="http%3A//en.cppreference.com/mwiki/index.php" class="new" title="cpp/concept/BinaryTypeTrait (page does not exist)"><span class="t-lines"><span>BinaryTypeTrait</span></span></a></div>
<div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div>
</div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table">
<div><a href="http%3A//en.cppreference.com/mwiki/index.php" class="new" title="cpp/concept/TransformationTrait (page does not exist)"><span class="t-lines"><span>TransformationTrait</span></span></a></div>
<div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div>
</div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table">
<div><a href="TrivialClock.html" title="cpp/concept/TrivialClock"><span class="t-lines"><span>TrivialClock</span></span></a></div>
<div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div>
</div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table">
<div><a href="LiteralType.html" title="cpp/concept/LiteralType"><span class="t-lines"><span>LiteralType</span></span></a></div>
<div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div>
</div></td></tr>
</table></div></td>
</tr>
</table></div>
<div></div>
</div></div>
</div>
<div class="t-navbar-sep"> </div>
</div>
<p>Encapsulates a memory allocation and deallocation strategy.
</p>
<p>Every standard library component that may need to allocate or release storage, from <code>std::string</code>, <code>std::vector</code>, and every container except <code>std::array</code>, to <code>std::shared_ptr</code> and <code>std::function</code>, does so through an <strong class="selflink"><code>Allocator</code></strong>: an object of a class type that satisfies the following requirements.
</p>
<p>Some requirements are optional: the template <span class="t-lc"><a href="../memory/allocator_traits.html" title="cpp/memory/allocator traits">std::allocator_traits</a></span> supplies the default implementations for all optional requirements, and all standard library containers and other allocator-aware classes access the allocator through <code>std::allocator_traits</code>, not directly.
</p>
<h3>
<span class="editsection">[<a href="http%3A//en.cppreference.com/mwiki/index.php" title="Edit section: Requirements">edit</a>]</span> <span class="mw-headline" id="Requirements">Requirements</span>
</h3>
<p>Given
</p>
<ul>
<li> <code>A</code>, an Allocator for type <code>T</code>
</li>
<li> <code>B</code>, the same Allocator for type <code>U</code>
</li>
<li> <code>ptr</code>, a value of type <code>allocator_traits&lt;A&gt;::pointer</code>, obtained by calling <span class="t-c"><span class="mw-geshi cpp source-cpp">allocator_traits<span class="sy1">&lt;</span>A<span class="sy1">&gt;</span><span class="sy4">::</span><span class="me2">allocate</span><span class="br0">(</span><span class="br0">)</span></span></span>
</li>
<li> <code>cptr</code>, a value of type <code>allocator_traits&lt;A&gt;::const_pointer</code>, obtained by conversion from <code>ptr</code>
</li>
<li> <code>vptr</code>, a value of type <code>allocator_traits&lt;A&gt;::void_pointer</code>, obtained by conversion from <code>ptr</code>
</li>
<li> <code>cvptr</code>, a value of type <code>allocator_traits&lt;A&gt;::const_void_pointer</code>, obtained by conversion from <code>cptr</code> or from <code>vptr</code>
</li>
<li> <code>xptr</code>, a dereferencable pointer to some type <code>X</code>
</li>
</ul>
<table class="wikitable">

<tr>
<th>Expression</th>
<th>Requirements</th>
<th>Return type
</th>
</tr>
<tr>
<td> <span class="t-c"><span class="mw-geshi cpp source-cpp">A<span class="sy4">::</span><span class="me2">pointer</span></span></span> <span class="t-mark">(optional)</span>
</td>
<td> Satisfies <a href="NullablePointer.html" title="cpp/concept/NullablePointer"><code>NullablePointer</code></a> and <a href="RandomAccessIterator.html" title="cpp/concept/RandomAccessIterator"><code>RandomAccessIterator</code></a>
</td>
<td>
</td>
</tr>
<tr>
<td> <span class="t-c"><span class="mw-geshi cpp source-cpp">A<span class="sy4">::</span><span class="me2">const_pointer</span></span></span> <span class="t-mark">(optional)</span>
</td>
<td> <code>A::pointer</code> is convertible to <code>A::const_pointer</code>. Satisfies <a href="NullablePointer.html" title="cpp/concept/NullablePointer"><code>NullablePointer</code></a> and <a href="RandomAccessIterator.html" title="cpp/concept/RandomAccessIterator"><code>RandomAccessIterator</code></a>
</td>
<td>
</td>
</tr>
<tr>
<td> <span class="t-c"><span class="mw-geshi cpp source-cpp">A<span class="sy4">::</span><span class="me2">void_pointer</span></span></span> <span class="t-mark">(optional)</span>
</td>
<td> <code>A::pointer</code> is convertible to <code>A::void_pointer</code>
<p><code>B::void_pointer</code> and <code>A::void_pointer</code> are the same type. Satisfies <a href="NullablePointer.html" title="cpp/concept/NullablePointer"><code>NullablePointer</code></a>
</p>
</td>
<td>
</td>
</tr>
<tr>
<td> <span class="t-c"><span class="mw-geshi cpp source-cpp">A<span class="sy4">::</span><span class="me2">const_void_pointer</span></span></span> <span class="t-mark">(optional)</span>
</td>
<td> <code>A::pointer</code>, <code>A::const_pointer</code>, and <code>A::void_pointer</code> are convertible to <code>A::const_void_pointer</code>
<p><code>B::const_void_pointer</code> and <code>A::const_void_pointer</code> are the same type. Satisfies <a href="NullablePointer.html" title="cpp/concept/NullablePointer"><code>NullablePointer</code></a>
</p>
</td>
<td>
</td>
</tr>
<tr>
<td> <span class="t-c"><span class="mw-geshi cpp source-cpp">A<span class="sy4">::</span><span class="me2">value_type</span></span></span>
</td>
<td>
</td>
<td> the type <code>T</code>
</td>
</tr>
<tr>
<td> <span class="t-c"><span class="mw-geshi cpp source-cpp">A<span class="sy4">::</span><span class="me2">size_type</span></span></span> <span class="t-mark">(optional)</span>
</td>
<td> <code>A::size_type</code> can represent the size of the largest object <code>A</code> can allocate
</td>
<td> unsigned integer type
</td>
</tr>
<tr>
<td> <span class="t-c"><span class="mw-geshi cpp source-cpp">A<span class="sy4">::</span><span class="me2">difference_type</span></span></span> <span class="t-mark">(optional)</span>
</td>
<td> <code>A::difference_type</code> can represent the difference of any two pointers to the objects allocated by <code>A</code>
</td>
<td> signed integer type
</td>
</tr>
<tr>
<td> <span class="t-c"><span class="mw-geshi cpp source-cpp">A<span class="sy4">::</span><span class="kw1">template</span> rebind<span class="sy1">&lt;</span>U<span class="sy1">&gt;</span><span class="sy4">::</span><span class="me2">other</span></span></span> <span class="t-mark">(optional[1])</span>
</td>
<td> for any <code>U</code>, <code>B::template rebind&lt;T&gt;::other</code> is <code>A</code>
</td>
<td> the type <code>B</code>
</td>
</tr>
<tr>
<td> <span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="sy2">*</span>ptr</span></span>
</td>
<td>
</td>
<td> <code>T&amp;</code>
</td>
</tr>
<tr>
<td> <span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="sy2">*</span>cptr</span></span>
</td>
<td> <span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="sy2">*</span>cptr</span></span> and <span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="sy2">*</span>ptr</span></span> identify the same object
</td>
<td> <code>const T&amp;</code>
</td>
</tr>
<tr>
<td> <span class="t-c"><span class="mw-geshi cpp source-cpp">ptr<span class="sy2">-</span><span class="sy1">&gt;</span>m</span></span>
</td>
<td> same as <span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="br0">(</span><span class="sy2">*</span>ptr<span class="br0">)</span>.<span class="me1">m</span></span></span>, if <span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="br0">(</span><span class="sy2">*</span>ptr<span class="br0">)</span>.<span class="me1">m</span></span></span> is well-defined
</td>
<td> the type of <code>T::m</code>
</td>
</tr>
<tr>
<td> <span class="t-c"><span class="mw-geshi cpp source-cpp">cptr<span class="sy2">-</span><span class="sy1">&gt;</span>m</span></span>
</td>
<td> same as <span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="br0">(</span><span class="sy2">*</span>cptr<span class="br0">)</span>.<span class="me1">m</span></span></span>, if <span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="br0">(</span><span class="sy2">*</span>cptr<span class="br0">)</span>.<span class="me1">m</span></span></span> is well-defined
</td>
<td> the type of <code>T::m</code>
</td>
</tr>
<tr>
<td> <span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="kw1">static_cast</span><span class="sy1">&lt;</span>A<span class="sy4">::</span><span class="me2">pointer</span><span class="sy1">&gt;</span><span class="br0">(</span>vptr<span class="br0">)</span></span></span>
</td>
<td> <span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="kw1">static_cast</span><span class="sy1">&lt;</span>A<span class="sy4">::</span><span class="me2">pointer</span><span class="sy1">&gt;</span><span class="br0">(</span>vptr<span class="br0">)</span> <span class="sy1">==</span> ptr</span></span>
</td>
<td> <code>A::pointer</code>
</td>
</tr>
<tr>
<td> <span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="kw1">static_cast</span><span class="sy1">&lt;</span>A<span class="sy4">::</span><span class="me2">const_pointer</span><span class="sy1">&gt;</span><span class="br0">(</span>cvptr<span class="br0">)</span></span></span>
</td>
<td> <span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="kw1">static_cast</span><span class="sy1">&lt;</span>A<span class="sy4">::</span><span class="me2">const_pointer</span><span class="sy1">&gt;</span><span class="br0">(</span>vptr<span class="br0">)</span> <span class="sy1">==</span> cptr</span></span>
</td>
<td> <code>A::const_pointer</code>
</td>
</tr>
<tr>
<td> <span class="t-c"><span class="mw-geshi cpp source-cpp">a.<span class="me1">allocate</span><span class="br0">(</span>n<span class="br0">)</span></span></span>
</td>
<td> allocates storage suitable for <code>n</code> objects of type <code>T</code>, but does not construct them. May throw exceptions.
</td>
<td> <code>A::pointer</code>
</td>
</tr>
<tr>
<td> <span class="t-c"><span class="mw-geshi cpp source-cpp">a.<span class="me1">allocate</span><span class="br0">(</span>n, cvptr<span class="br0">)</span></span></span> <span class="t-mark">(optional)</span>
</td>
<td> same as <code>a.allocate(n)</code>, but may use <code>cvptr</code> (a pointer obtained from <code>a.allocate()</code> or <code>nullptr_t</code>) in unspecified manner to aid locality
</td>
<td> <code>A::pointer</code>
</td>
</tr>
<tr>
<td> <span class="t-c"><span class="mw-geshi cpp source-cpp">a.<span class="me1">deallocate</span><span class="br0">(</span>ptr, n<span class="br0">)</span></span></span>
</td>
<td> deallocates storage previously allocated by a call to <span class="t-c"><span class="mw-geshi cpp source-cpp">a.<span class="me1">allocate</span><span class="br0">(</span>n<span class="br0">)</span></span></span>. Does not call destructors, if any objects were constructed, they must be destroyed before calling <span class="t-c"><span class="mw-geshi cpp source-cpp">a.<span class="me1">deallocate</span><span class="br0">(</span><span class="br0">)</span></span></span>. Does not throw exceptions.
</td>
<td> (not used)
</td>
</tr>
<tr>
<td> <span class="t-c"><span class="mw-geshi cpp source-cpp">a.<span class="me1">max_size</span><span class="br0">(</span><span class="br0">)</span></span></span> <span class="t-mark">(optional)</span>
</td>
<td> the largest value that can be passed to <code>A::allocate()</code>
</td>
<td> <code>A::size_type</code>
</td>
</tr>
<tr>
<td> <span class="t-c"><span class="mw-geshi cpp source-cpp">a1 <span class="sy1">==</span> a2</span></span>
</td>
<td> returns <span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="kw2">true</span></span></span> only if the storage allocated by the allocator <code>a1</code> can be deallocated through <code>a2</code>. Establishes reflexive, symmetric, and transitive relationship. Does not throw exceptions.
</td>
<td> <span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="kw4">bool</span></span></span>
</td>
</tr>
<tr>
<td> <span class="t-c"><span class="mw-geshi cpp source-cpp">a1 <span class="sy3">!</span><span class="sy1">=</span> a2</span></span>
</td>
<td> same as <span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="sy3">!</span><span class="br0">(</span>a1<span class="sy1">==</span>a2<span class="br0">)</span></span></span>
</td>
<td> <span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="kw4">bool</span></span></span>
</td>
</tr>
<tr>
<td> <span class="t-c"><span class="mw-geshi cpp source-cpp">A a1<span class="br0">(</span>a<span class="br0">)</span></span></span>
<p><span class="t-c"><span class="mw-geshi cpp source-cpp">A a1 <span class="sy1">=</span> a</span></span>
</p>
</td>
<td> Copy-constructs <code>a1</code> such that <span class="t-c"><span class="mw-geshi cpp source-cpp">a1 <span class="sy1">==</span> a</span></span>. Does not throw exceptions. (Note: every <code>Allocator</code> also satisfies <a href="CopyConstructible.html" title="cpp/concept/CopyConstructible"><code>CopyConstructible</code></a>)
</td>
<td>
</td>
</tr>
<tr>
<td> <span class="t-c"><span class="mw-geshi cpp source-cpp">A a<span class="br0">(</span>b<span class="br0">)</span></span></span>
</td>
<td> Constructs <code>a</code> such that <span class="t-c"><span class="mw-geshi cpp source-cpp">B<span class="br0">(</span>a<span class="br0">)</span><span class="sy1">==</span>b</span></span> and <span class="t-c"><span class="mw-geshi cpp source-cpp">A<span class="br0">(</span>b<span class="br0">)</span><span class="sy1">==</span>a</span></span>. Does not throw exceptions.
</td>
<td>
</td>
</tr>
<tr>
<td> <span class="t-c"><span class="mw-geshi cpp source-cpp">A a1<span class="br0">(</span><a href="../utility/move.html"><span class="kw914">std::<span class="me2">move</span></span></a><span class="br0">(</span>a<span class="br0">)</span><span class="br0">)</span></span></span>
<p><span class="t-c"><span class="mw-geshi cpp source-cpp">A a1 <span class="sy1">=</span> <a href="../utility/move.html"><span class="kw914">std::<span class="me2">move</span></span></a><span class="br0">(</span>a<span class="br0">)</span></span></span>
</p>
</td>
<td> Constructs <code>a1</code> such that it equals the prior value of <code>a</code>. Does not throw exceptions.
</td>
<td>
</td>
</tr>
<tr>
<td> <span class="t-c"><span class="mw-geshi cpp source-cpp">A a<span class="br0">(</span><a href="../utility/move.html"><span class="kw914">std::<span class="me2">move</span></span></a><span class="br0">(</span>b<span class="br0">)</span><span class="br0">)</span></span></span>
</td>
<td> Constructs <code>a</code> such that it equals the prior value of <code>A(b)</code>. Does not throw exceptions.
</td>
<td>
</td>
</tr>
<tr>
<td> <span class="t-c"><span class="mw-geshi cpp source-cpp">a.<span class="me1">construct</span><span class="br0">(</span>xptr, args<span class="br0">)</span></span></span> <span class="t-mark">(optional)</span>
</td>
<td> Constructs an object of type <code>X</code> in previously-allocated storage at the address pointed to by <code>xptr</code>, using args as the constructor arguments
</td>
<td>
</td>
</tr>
<tr>
<td> <span class="t-c"><span class="mw-geshi cpp source-cpp">a.<span class="me1">destroy</span><span class="br0">(</span>xptr<span class="br0">)</span></span></span> <span class="t-mark">(optional)</span>
</td>
<td> Destructs an object of type <code>X</code> pointed to by <code>xptr</code>, but does not deallocate any storage.
</td>
<td>
</td>
</tr>
<tr>
<td> <span class="t-c"><span class="mw-geshi cpp source-cpp">a.<span class="me1">select_on_container_copy_construction</span><span class="br0">(</span><span class="br0">)</span></span></span> <span class="t-mark">(optional)</span>
</td>
<td> Provides an instance of <code>A</code> to be used by the container that is copy-constructed from the one that uses <code>a</code> currently. Usually returns either a copy of <code>a</code> or a default-constructed <code>A()</code>.
</td>
<td> <code>A</code>
</td>
</tr>
<tr>
<td> <span class="t-c"><span class="mw-geshi cpp source-cpp">a.<span class="me1">propagate_on_container_copy_assignment</span></span></span> <span class="t-mark">(optional)</span>
</td>
<td> <span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="kw2">true</span></span></span> if the allocator of type <code>A</code> needs to be copied when the container that uses it is copy-assigned. Note that if the allocators of the source and the target containers do not compare equal, copy assignment has to deallocate the target's memory using the old allocator and then allocate it using the new allocator before copying the elements (and the allocator).
</td>
<td> <span class="t-lc"><a href="../types/integral_constant.html" title="cpp/types/integral constant">std::true_type</a></span> or <span class="t-lc"><a href="../types/integral_constant.html" title="cpp/types/integral constant">std::false_type</a></span> or derived from such
</td>
</tr>
<tr>
<td> <span class="t-c"><span class="mw-geshi cpp source-cpp">a.<span class="me1">propagate_on_container_move_assignment</span></span></span> <span class="t-mark">(optional)</span>
</td>
<td> <span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="kw2">true</span></span></span> if the allocator of type <code>A</code> needs to be copied when the container that uses it is move-assigned. If this member is <span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="kw2">false</span></span></span> and the allocators of the source and the target containers do not compare equal, move assignment cannot take ownership of the source memory and must move-assign or move-construct the elements individually, resizing its own memory as needed.
</td>
<td> <span class="t-lc"><a href="../types/integral_constant.html" title="cpp/types/integral constant">std::true_type</a></span> or <span class="t-lc"><a href="../types/integral_constant.html" title="cpp/types/integral constant">std::false_type</a></span> or derived from such
</td>
</tr>
<tr>
<td> <span class="t-c"><span class="mw-geshi cpp source-cpp">a.<span class="me1">propagate_on_container_swap</span></span></span> <span class="t-mark">(optional)</span>
</td>
<td> <span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="kw2">true</span></span></span> if the allocators of type <code>A</code> need to be swapped when two containers that use them are swapped. If this member is <span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="kw2">false</span></span></span> and the allocators of the two containers do not compare equal, the behavior of container swap is undefined.
</td>
<td> <span class="t-lc"><a href="../types/integral_constant.html" title="cpp/types/integral constant">std::true_type</a></span> or <span class="t-lc"><a href="../types/integral_constant.html" title="cpp/types/integral constant">std::false_type</a></span> or derived from such
</td>
</tr>
</table>
<p>Notes:
[1] rebind is only optional (provided by <span class="t-lc"><a href="../memory/allocator_traits.html" title="cpp/memory/allocator traits">std::allocator_traits</a></span>) if this allocator is a template of the form <span class="t-c"><span class="mw-geshi cpp source-cpp">SomeAllocator<span class="sy1">&lt;</span>T, Args<span class="sy1">&gt;</span></span></span>, where <code>Args</code> is zero or more additional template parameters.
</p>
 <table class="t-rev-begin">
<tr class="t-rev t-since-cxx14">
<td>
<p>Given
</p>
<ul><li> <code>x1</code> and <code>x2</code>, objects of (possibly different) types <code>X::void_pointer</code>, <code>X::const_void_pointer</code>, <code>X::pointer</code>, or <code>X::const_pointer</code>
</li></ul>
<p>Then, x1 and x2 are <i>equivalently-valued</i> pointer values, if and only if both <code>x1</code> and <code>x2</code> can be explicitly converted to the two corresponding objects <code>px1</code> and <code>px2</code> of type <code>X::const_pointer</code>, using a sequence of <code>static_casts</code> using only these four types, and the expression <span class="t-c"><span class="mw-geshi cpp source-cpp">px1 <span class="sy1">==</span> px2</span></span> evaluates to true
</p>
<p>Given
</p>
<ul><li> <code>w1</code> and <code>w2</code>, objects of type <code>X::void_pointer</code>.
</li></ul>
<p>Then for the expression <span class="t-c"><span class="mw-geshi cpp source-cpp">w1 <span class="sy1">==</span> w2</span></span> and <span class="t-c"><span class="mw-geshi cpp source-cpp">w1 <span class="sy3">!</span><span class="sy1">=</span> w2</span></span> either or both objects may be replaced by an <i>equivalently-valued</i> object of type <code>X::const_void_pointer</code> with no change in semantics.
</p>
<p>Given
</p>
<ul><li> <code>p1</code> and <code>p2</code>, objects of type <code>X::pointer</code>
</li></ul>
<p>Then, for the expressions <span class="t-c"><span class="mw-geshi cpp source-cpp">p1 <span class="sy1">==</span> p2</span></span>, <span class="t-c"><span class="mw-geshi cpp source-cpp">p1 <span class="sy3">!</span><span class="sy1">=</span> p2</span></span>, <span class="t-c"><span class="mw-geshi cpp source-cpp">p1 <span class="sy1">&lt;</span> p2</span></span> <span class="t-c"><span class="mw-geshi cpp source-cpp">p1 <span class="sy1">&lt;=</span> p2</span></span>, <span class="t-c"><span class="mw-geshi cpp source-cpp">p1 <span class="sy1">&gt;=</span> p2</span></span>, <span class="t-c"><span class="mw-geshi cpp source-cpp">p1 <span class="sy1">&gt;</span> p2</span></span>, <span class="t-c"><span class="mw-geshi cpp source-cpp">p1 <span class="sy2">-</span> p2</span></span>} either or both objects may be replaced by an <i>equivalently-valued</i> object of type <code>X::const_pointer</code> with no change in semantics.
</p>
<p>The above requirements make it possible to compare <a href="Container.html" title="cpp/concept/Container"><code>Container</code></a>'s iterators and const_iterators.
</p>
</td>
<td><span class="t-mark-rev t-since-cxx14">(since C++14)</span></td>
</tr>
</table>
<h3>
<span class="editsection">[<a href="http%3A//en.cppreference.com/mwiki/index.php" title="Edit section: Examples">edit</a>]</span> <span class="mw-headline" id="Examples">Examples</span>
</h3>
<div class="t-example">
<p>a minimum C++11 allocator 
</p>
<div class="t-example-live-link"><div class="coliru-btn coliru-btn-run-init">Run this code</div></div>
<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="cpp source-cpp"><pre class="de1"><span class="kw1">template</span> <span class="sy1">&lt;</span><span class="kw1">class</span> Tp<span class="sy1">&gt;</span>
<span class="kw1">struct</span> SimpleAllocator <span class="br0">{</span>
  <span class="kw1">typedef</span> Tp value_type<span class="sy4">;</span>
  SimpleAllocator<span class="br0">(</span><span class="coMULTI">/*ctor args*/</span><span class="br0">)</span><span class="sy4">;</span>
  <span class="kw1">template</span> <span class="sy1">&lt;</span><span class="kw1">class</span> T<span class="sy1">&gt;</span> SimpleAllocator<span class="br0">(</span><span class="kw4">const</span> SimpleAllocator<span class="sy1">&lt;</span>T<span class="sy1">&gt;</span><span class="sy3">&amp;</span> other<span class="br0">)</span><span class="sy4">;</span>
  Tp<span class="sy2">*</span> allocate<span class="br0">(</span><a href="../types/size_t.html"><span class="kw100">std::<span class="me2">size_t</span></span></a> n<span class="br0">)</span><span class="sy4">;</span>
  <span class="kw4">void</span> deallocate<span class="br0">(</span>Tp<span class="sy2">*</span> p, <a href="../types/size_t.html"><span class="kw100">std::<span class="me2">size_t</span></span></a> n<span class="br0">)</span><span class="sy4">;</span>
<span class="br0">}</span><span class="sy4">;</span>
<span class="kw1">template</span> <span class="sy1">&lt;</span><span class="kw1">class</span> T, <span class="kw1">class</span> U<span class="sy1">&gt;</span>
<span class="kw4">bool</span> operator<span class="sy1">==</span><span class="br0">(</span><span class="kw4">const</span> SimpleAllocator<span class="sy1">&lt;</span>T<span class="sy1">&gt;</span><span class="sy3">&amp;</span>, <span class="kw4">const</span> SimpleAllocator<span class="sy1">&lt;</span>U<span class="sy1">&gt;</span><span class="sy3">&amp;</span><span class="br0">)</span><span class="sy4">;</span>
<span class="kw1">template</span> <span class="sy1">&lt;</span><span class="kw1">class</span> T, <span class="kw1">class</span> U<span class="sy1">&gt;</span>
<span class="kw4">bool</span> operator<span class="sy3">!</span><span class="sy1">=</span><span class="br0">(</span><span class="kw4">const</span> SimpleAllocator<span class="sy1">&lt;</span>T<span class="sy1">&gt;</span><span class="sy3">&amp;</span>, <span class="kw4">const</span> SimpleAllocator<span class="sy1">&lt;</span>U<span class="sy1">&gt;</span><span class="sy3">&amp;</span><span class="br0">)</span><span class="sy4">;</span></pre></div></div>
<p><br> 
</p>
</div>

<!-- 
NewPP limit report
Preprocessor visited node count: 6649/1000000
Preprocessor generated node count: 8339/1000000
Post‐expand include size: 144258/2097152 bytes
Template argument size: 27285/2097152 bytes
Highest expansion depth: 16/40
Expensive parser function count: 0/100
-->

<!-- Saved in parser cache with key mwiki1-mwiki_en_:pcache:idhash:9133-0!*!0!!*!*!* and timestamp 20140322231546 -->
</div>                    <!-- /bodycontent -->
                                        <!-- printfooter -->
                    <div class="printfooter">
                    Retrieved from "<a href="http%3A//en.cppreference.com/mwiki/index.php">http://en.cppreference.com/mwiki/index.php?title=cpp/concept/Allocator&amp;oldid=68221</a>"                    </div>
                    <!-- /printfooter -->
                                                            <!-- catlinks -->
                    <div id="catlinks" class="catlinks catlinks-allhidden"></div>                    <!-- /catlinks -->
                                                            <div class="visualClear"></div>
                    <!-- debughtml -->
                                        <!-- /debughtml -->
                </div>
                <!-- /bodyContent -->
            </div>
        </div>
        <!-- /content -->
        <!-- footer -->
        
        <!-- /footer -->
        <script>if(window.mw){
mw.loader.state({"site":"loading","user":"missing","user.groups":"ready"});
}</script>
<script src="../../../common/skin_scripts.js"></script>
<script>if(window.mw){
mw.loader.load(["mediawiki.action.view.postEdit","mediawiki.user","mediawiki.page.ready","mediawiki.searchSuggest","mediawiki.hidpi","ext.gadget.ColiruCompiler"], null, true);
}</script>
<script src="../../../common/site_scripts.js"></script>

<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-2828341-1']);
_gaq.push(['_setDomainName', 'cppreference.com']);
_gaq.push(['_trackPageview']);
</script><!-- Served in 7.872 secs. -->
	</body>
<!-- Cached 20140322231546 -->
</html>
